﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<HTML>
<?php 
include 'include/config.php';
include 'include/opendb.php';
include 'include/iprestrict.php';
?>
<HEAD><META http-equiv="Content-Type" content="text/html; charset=UTF-8">
<TITLE>LSID系统</TITLE>
<STYLE type="text/css" media="all">@import "jscss/style.css";</STYLE>
<STYLE type="text/css" media="all">@import "jscss/autocomplete.css";</STYLE>
<SCRIPT type="text/javascript" src="jscss/jquery.js"></SCRIPT> 
<SCRIPT type="text/javascript" src="jscss/autocomplete.js"></SCRIPT> 
<SCRIPT type="text/javascript">
 $().ready(function() {
var ctry=document.getElementById("swchlat");
var ctryIdx=ctry.options[ctry.selectedIndex].value;
	    $("#sname").autocomplete("include/auto.php?qw="+ctryIdx, { matchContains:true, minChars: 0});
		 });
		 
function chlat(){
var ctry=document.getElementById("swchlat");
var ctryIdx=ctry.options[ctry.selectedIndex].value;
document.getElementById("sname").value='';
$("#sname").autocomplete("include/auto.php?qw="+ctryIdx, { matchContains:true, minChars: 0});
}
</SCRIPT>
</HEAD>

<body> 
<TABLE width="900" border="0" align="center" cellspacing="0" cellpadding="0">
<TBODY>
<TR> <TD valign="top" width="960" height="118" background="pics/main.jpg"></TD></TR>
<TR><TD><TABLE width="910px" border="0" align="center"><TR>
<td width="434">
<?php
 echo $navbar;  //菜单设置
?>
</td>
<TD align='right' width="466">
<form action="" method="post">
<select id="swchlat" name="ntype" onchange="chlat();">
 <option value="lat" selected>学名</option> 
 <option value="ch">中文名</option> 
</select>
<INPUT value="" type="text" id="sname" name="sname" size="35"><INPUT  value=" 检索 "  type="submit">
</form>
</td></tr></table>
</TD> </TR>
 <TR><TD valign="top" align="center">
<hr style='BORDER-BOTTOM-STYLE: dotted; BORDER-LEFT-STYLE: dotted; BORDER-RIGHT-STYLE: dotted; BORDER-TOP-STYLE: dotted' color=#FFFFF size=1> 
<?php
if(isset($_POST['sname']))
{
$sname=$_POST['sname'];   $ntype=$_POST['ntype'];
mysql_query("set names 'utf8'");

if($ntype=='lat')
  $query="select LSID from ".$main_table." where ScientificName='".$sname."' LIMIT 1";
else  $query="select LSID from ".$main_table." where CommonName='".$sname."' LIMIT 1";

if($result = mysql_query($query)){
  if($rows = mysql_fetch_assoc($result)){  
   header("location:lsid.php?lsid=urn:lsid:cvh.org.cn:names:".$rows["LSID"]);  //得到唯一的名称ID之后，自动跳转到改名成指定的LSID路径
 } 
}
echo "没有找到你要的记录";
}

else if(isset($_GET['lsid']))
{
$tempid=explode(':',$_GET['lsid']);
$fid=$tempid[4];
$ntype=explode('_',$fid);

if($ntype[0]=="cnpc"){
mysql_query("set names 'utf8'");
//
$query="select ScientificName,CommonName,count(*) cc from ".$main_table." where LSID='".$fid."' group by LSID";
$GeoQuery="select count(*) from ".$main_table." where LSID='".$fid."' and length(DecimalLongitude)>2";
$result = mysql_query($query) or die("检索出错");
$GeoResult = mysql_query($GeoQuery) or die("检索出错");

if ($row = mysql_fetch_array($result)) {$sname=$row['ScientificName'].','.$row['CommonName']; $countAll=$row['cc'];}
if ($GeoRow = mysql_fetch_array($GeoResult)) $countGeo=$GeoRow[0];

if($result){
echo '<h3>'.$sname.',本馆标本总数：'.$countAll.'（地标化：'.$countGeo.
    '）<a href="advquery.php?lname='.$row['ScientificName'].'">详情</a></h3>';
?>
<IFRAME border="0"  src="<?php echo $cvh_lsid;?>map.php?fid=<?php echo $Code.':'.$fid;?>&format=kml" frameBorder="0" width="700"  height="500" scrolling="no"> </IFRAME>
<br><h3>该种在CVH主馆中的空间分布：
<?php echo '<a href="'.$cvh_lsid.'index.php?lsid=urn:lsid:cvh.org.cn:names:'.$fid.'" target="_blank">'.'CVH主馆LSID信息</a></h3>';
		   ?>
<IFRAME border="0"  src="<?php echo $cvh_lsid;?>map.php?fid=CVH:<?php echo $fid;?>&format=kml" frameBorder="0" width="700"  height="500" scrolling="no">  </IFRAME>
<?php
   }
  }
}
else  echo  '';
?>

 </TD></TR>
<tr><td align="left" valign="top"> 	
 <hr style='BORDER-BOTTOM-STYLE: dotted; BORDER-LEFT-STYLE: dotted; BORDER-RIGHT-STYLE: dotted; BORDER-TOP-STYLE: dotted' color=#FFFFF size=1> <table id="flex1" style="display:none"></table>
	</td>
</tr><TR><TD height="70" align="center" bgcolor="#d1ab7a"><br><h2>
        <?php
       echo $footer;
       ?>
       </h2></TD>
</TR></TBODY></TABLE>
</BODY></HTML>